package com.hd.sup.modules.alarm.wrapper;

import com.hd.common.constant.BizConstant;
import com.hd.common.page.BaseControllerWrapper;
import com.hd.common.utils.DateUtil;
import com.hd.sup.modules.alarm.util.TemplateUtils;

import java.util.Date;
import java.util.Map;

/**
 * @author chentl
 * @version V1.0
 * @Project 交通运输第三方监测平台
 * @Title AlarmWrapper.java
 * @Description 分析报告装饰器
 * @Package com.hd.sup.modules.alarm.wrapper
 * @date 2020/12/31 2:48 下午
 * @Copyright: 深圳市宏电技术股份有限公司 All rights reserved.
 */
public class AlarmReportWrapper extends BaseControllerWrapper {

    public AlarmReportWrapper(Object obj) {
        super(obj);
    }

    @Override
    protected void warpTheMap(Map<String, Object> map) {
        //报警开始时间
        Object start_date = map.get("start_date");
        if (start_date != null) {
            Date date = (Date) start_date;
            String dateStr = DateUtil.format(date, BizConstant.Common.DATE_FORMAT_DAY.key());
            map.put("start_date", dateStr);
        }

        //离线时间
        Object end_date = map.get("end_date");
        if (end_date != null) {
            Date date = (Date) end_date;
            String dateStr = DateUtil.format(date, BizConstant.Common.DATE_FORMAT_DAY.key());
            map.put("end_date", dateStr);
        }

        //创建时间
        Object create_time = map.get("create_time");
        if (create_time != null) {
            Date date = (Date) create_time;
            String dateStr = DateUtil.format(date, BizConstant.Common.DATE_FORMAT_SECOND.key());
            map.put("create_time", dateStr);
        }

        //time_flag
        Object time_flag = map.get("time_flag");
        if (time_flag != null) {
            String timeStr = TemplateUtils.getReportNameRangeDesc((String) time_flag);
            map.put("time_flag", timeStr);
        }

        //generate_status
        Object generate_status = map.get("generate_status");
        if (generate_status != null) {
            String statusStr = BizConstant.GenerateStatus.get((String) generate_status);
            map.put("generate_status", statusStr);
        }

    }
}